import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/auth/face_recog_entity.dart';

FaceRecogEntity $FaceRecogEntityFromJson(Map<String, dynamic> json) {
  final FaceRecogEntity faceRecogEntity = FaceRecogEntity();
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    faceRecogEntity.status = status;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    faceRecogEntity.image = image;
  }
  final List<FaceRecogResults>? results = (json['results'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<FaceRecogResults>(e) as FaceRecogResults).toList();
  if (results != null) {
    faceRecogEntity.results = results;
  }
  return faceRecogEntity;
}

Map<String, dynamic> $FaceRecogEntityToJson(FaceRecogEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['status'] = entity.status;
  data['image'] = entity.image;
  data['results'] = entity.results?.map((v) => v.toJson()).toList();
  return data;
}

extension FaceRecogEntityExtension on FaceRecogEntity {
  FaceRecogEntity copyWith({
    String? status,
    String? image,
    List<FaceRecogResults>? results,
  }) {
    return FaceRecogEntity()
      ..status = status ?? this.status
      ..image = image ?? this.image
      ..results = results ?? this.results;
  }
}

FaceRecogResults $FaceRecogResultsFromJson(Map<String, dynamic> json) {
  final FaceRecogResults faceRecogResults = FaceRecogResults();
  final FaceRecogResultsPoints? points = jsonConvert.convert<FaceRecogResultsPoints>(json['points']);
  if (points != null) {
    faceRecogResults.points = points;
  }
  final double? simil = jsonConvert.convert<double>(json['simil']);
  if (simil != null) {
    faceRecogResults.simil = simil;
  }
  final String? personId = jsonConvert.convert<String>(json['person_id']);
  if (personId != null) {
    faceRecogResults.personId = personId;
  }
  return faceRecogResults;
}

Map<String, dynamic> $FaceRecogResultsToJson(FaceRecogResults entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['points'] = entity.points?.toJson();
  data['simil'] = entity.simil;
  data['person_id'] = entity.personId;
  return data;
}

extension FaceRecogResultsExtension on FaceRecogResults {
  FaceRecogResults copyWith({
    FaceRecogResultsPoints? points,
    double? simil,
    String? personId,
  }) {
    return FaceRecogResults()
      ..points = points ?? this.points
      ..simil = simil ?? this.simil
      ..personId = personId ?? this.personId;
  }
}

FaceRecogResultsPoints $FaceRecogResultsPointsFromJson(Map<String, dynamic> json) {
  final FaceRecogResultsPoints faceRecogResultsPoints = FaceRecogResultsPoints();
  final double? centerY = jsonConvert.convert<double>(json['center_y']);
  if (centerY != null) {
    faceRecogResultsPoints.centerY = centerY;
  }
  final double? centerX = jsonConvert.convert<double>(json['center_x']);
  if (centerX != null) {
    faceRecogResultsPoints.centerX = centerX;
  }
  return faceRecogResultsPoints;
}

Map<String, dynamic> $FaceRecogResultsPointsToJson(FaceRecogResultsPoints entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['center_y'] = entity.centerY;
  data['center_x'] = entity.centerX;
  return data;
}

extension FaceRecogResultsPointsExtension on FaceRecogResultsPoints {
  FaceRecogResultsPoints copyWith({
    double? centerY,
    double? centerX,
  }) {
    return FaceRecogResultsPoints()
      ..centerY = centerY ?? this.centerY
      ..centerX = centerX ?? this.centerX;
  }
}
